package com.ukao.cashregister.ui.setting;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.ukao.cashregister.R;
import com.ukao.cashregister.base.BaseFragment;
import com.ukao.cashregister.consts.SaveParamets;
import com.ukao.cashregister.utils.CheckUtils;
import com.ukao.cashregister.utils.MyDateUtils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * 门店信息
 */
public class StoreNameFragment extends BaseFragment {

    private static final String ARG_PARAM1 = "param1";
    private static final String ARG_PARAM2 = "param2";
    @BindView(R.id.store_name)
    TextView storeName;
    @BindView(R.id.code)
    TextView code;
    @BindView(R.id.createTime)
    TextView createTime;
    @BindView(R.id.user_info_coupons_layout)
    LinearLayout userInfoCouponsLayout;
    @BindView(R.id.addrDesc)
    TextView addrDesc;
    Unbinder unbinder;
    @BindView(R.id.mercInfo)
    TextView mercInfo;


    private String mParam1;
    private String mParam2;


    public static StoreNameFragment newInstance(String param1, String param2) {
        StoreNameFragment fragment = new StoreNameFragment();
        Bundle args = new Bundle();
        args.putString(ARG_PARAM1, param1);
        args.putString(ARG_PARAM2, param2);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            mParam1 = getArguments().getString(ARG_PARAM1);
            mParam2 = getArguments().getString(ARG_PARAM2);
        }
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.fragment_store_name, container, false);
        unbinder = ButterKnife.bind(this, view);
        return view;
    }

    @Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        super.onLazyInitView(savedInstanceState);
        initView();
    }

    @Override
    protected void initView() {
        mercInfo.setText(SaveParamets.getMercInfo());
        storeName.setText(SaveParamets.getStoreName());
        code.setText(SaveParamets.getCode());
        createTime.setText(CheckUtils.isEmpty(SaveParamets.getCreateTimep()) ? "" : MyDateUtils.formatDataTime(Long.parseLong(SaveParamets.getCreateTimep())));
        addrDesc.setText(SaveParamets.getRegionalDesc() + SaveParamets.getAddrDesc());

    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }
}
